<% layout('/layouts/_default.html', {title: '参数设置', libs: ['dataGrid']}){ %>
<div class="main-content">
  <div class="box box-main">
    <div class="box-header">
      <div class="box-title" title="读取顺序：JVM系统参数 -> jeesite.yml -> 本窗口中的参数，读取参数方法：Global.getConfig('参数键名')">
        <i class="fa icon-wrench"></i> 参数设置 <i class="fa icon-question f14"></i>
      </div>
      <div class="box-tools pull-right">
        <a href="#" class="btn btn-default" id="btnSearch" title="查询"><i class="fa fa-search"></i> 查询</a>
        <a href="${ctxPath}/config/form?op=add" class="btn btn-default btnTool" title="新增参数"><i class="fa fa-plus"></i> 新增</a>
        <a href="#" class="btn btn-default" id="btnUpdateCache" title="清理全部缓存，包括属性文件的配置"><i class="fa fa-refresh"></i> 清理全部缓存</a>
      </div>
    </div>
    <div class="box-body">
      <#form:form id="searchForm" model="${row}" action="${ctxPath}/config/listData" method="post" class="form-inline "
          data-page-no="${parameter.pageNo}" data-page-size="${parameter.pageSize}" data-order-by="${parameter.orderBy}">
        <div class="form-group">
          <label class="control-label">参数名称：</label>
          <div class="control-inline">
            <#form:input path="configName" maxlength="100" class="form-control" />
          </div>
        </div>
        <div class="form-group">
          <label class="control-label">参数键名：</label>
          <div class="control-inline">
            <#form:input path="configKey_like" maxlength="100" class="form-control" />
          </div>
        </div>
        <div class="form-group">
          <label class="control-label">是否系统：</label>
          <div class="control-inline width-60">
            <#form:select path="isSys" dictType="sys_yes_no" blankOption="true" class="form-control"/>
          </div>
        </div>
        <div class="form-group">
          <button type="submit" class="btn btn-primary btn-sm">查询</button>
          <button type="reset" class="btn btn-default btn-sm">重置</button>
        </div>
      </#form:form>
      <table id="dataGrid"></table>
      <div id="dataGridPage"></div>
    </div>
  </div>
</div>
<% } %>
<script>
// 初始化DataGrid对象
$('#dataGrid').dataGrid({
  searchForm: $("#searchForm"),
  columnModel: [ 
    {header:'参数名称', name:'configName', index:'a.config_name', width:200, formatter: function(val, obj, row, act){
      return '<a href="${ctxPath}/config/form?id='+row.id+'" class="btnList" data-title="编辑参数">'+val+'</a>';
    }},
    {header:'参数键名', name:'configKey', index:'a.config_key', width:200},
    {header:'参数键值', name:'configValue', sortable:false, width:200, classes:"nowrap"},
    {header:'系统参数', name:'isSys', index:'a.is_sys', width:80, align:"center", formatter: function(val, obj, row, act){
      return js.getDictLabel(${@DictUtil.getDictListJson('sys_yes_no')}, val, '未知', true);
    }},
    {header:'操作', name:'actions', width:100, sortable:false, title:false, formatter: function(val, obj, row, act){
      var actions = [];
      actions.push('<a href="${ctxPath}/config/form?id='+row.id+'" class="btnList" title="编辑参数"><i class="fa fa-pencil"></i></a>&nbsp;');
      actions.push('<a href="${ctxPath}/config/delete?id='+row.id+'" class="btnList" title="删除参数" data-confirm="确认要删除该参数吗？"><i class="fa fa-trash-o"></i></a>&nbsp;');
      return actions.join('');
    }}
  ],
  // 加载成功后执行事件
  ajaxSuccess: function(data){
    
  }
});

// 更新平台中的全部缓存，包含属性配置文件。
$("#btnUpdateCache").click(function(){ 
  js.ajaxSubmit("${ctxPath}/config/clearAll", function(data){
    js.showMessage(data.message);
  });
  return false;
});
</script>